package k.daniel.android.view;

import android.util.Log;
import android.view.View;

/**
 */
public class MeasureHelper {
    public static void logMeasureInfo(Object obj,int widthMeasureSpec, int heightMeasureSpec) {
        int widthMode = View.MeasureSpec.getMode(widthMeasureSpec);
        int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
        int sizeWidth = View.MeasureSpec.getSize(widthMeasureSpec);
        int sizeHeight = View.MeasureSpec.getSize(heightMeasureSpec);

        Log.i(obj.getClass().getSimpleName()+"  Measure-Width", getModeDescription(widthMode) + "  " + sizeWidth);
        Log.i(obj.getClass().getSimpleName()+"  Measure-Height", getModeDescription(heightMode) + "  " + sizeHeight);
    }

    private static String getModeDescription(int widthMode) {
        String mode = null;
        switch (widthMode) {
            case View.MeasureSpec.EXACTLY:
                mode = "EXACTLY";
                break;
            case View.MeasureSpec.AT_MOST:
                mode = "AT_MOST";
                break;
            case View.MeasureSpec.UNSPECIFIED:
                mode = "UNSPECIFIED";
                break;
        }
        return mode;
    }

}
